#include "functiondef.h"
#include <sstream>
namespace dyngen {
	FunctionDef::FunctionDef(const std::string& name, const std::string& returnType, const StringVec& paramVec):
	m_name(name),
	m_returnType(returnType),
	m_paramVec(paramVec)
    {
	}
	std::string FunctionDef::functionPtrType() const {
		std::stringstream ss;
		ss << "(" << returnType() << "(*)" << formatParamVec(paramVec()) << ")";
		return ss.str();
	}

	std::string formatParamVec(const StringVec& v) {
		std::stringstream ss;
		ss << "(";
		for(StringVec::const_iterator it = v.begin(); it != v.end(); ++it) {
			if(it != v.begin()) {
				ss << ", ";
			}
			ss << *it;
		}
		ss << ")";
		return ss.str();
	}

}